import axios from "axios";
// axios.defaults.baseURL = 'http://192.168.3.12:5568/platform-api/'
axios.defaults.baseURL = 'https://d.xbdymgc.top/platform-api/'
axios.defaults.timeout = 600000 //10分钟
    //过时时间为时间为10分钟
    // 请求拦截
axios.interceptors.request.use(
    (config) => {
        let token = localStorage.getItem("WExintoken");
        if (token) {
            config.headers["Authorization"] = `Bearer ${token}`;
        }
        return config;
    },
    (error) => {
        return Promise.reject(error);
    }
);

// 响应拦截
axios.interceptors.response.use((response) => {
    return Promise.resolve(response) //响应成功进行处理
}, (error) => {
    return Promise.reject(error);
})


//对post进行封装
export const post = (url, data, headers) => {
    return axios({
        method: 'POST',
        url: url,
        data: data,
        headers: headers
    })
}

//对get进行封装
export const get = (url, data, headers) => {
    return axios({
        method: 'GET',
        url: url,
        params: data,
        headers: headers
    })
}